package org.nfr;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.*;

import java.io.InputStream;
import java.util.Set;

public class OntologyLoader {
    private OWLOntologyManager manager;
    private OWLOntology ontology;

    public void loadOntology(String path) throws Exception {
        manager = OWLManager.createOWLOntologyManager();
        InputStream in = getClass().getClassLoader().getResourceAsStream(path);
        if (in == null) {
            throw new RuntimeException("❌ 找不到本体文件: " + path);
        }
        ontology = manager.loadOntologyFromOntologyDocument(in);
        System.out.println("✅ OWL 本体加载成功: " + path);
    }

    public OWLOntology getOntology() {
        return ontology;
    }

    public void printOntologyAxioms() {
        System.out.println("📚 当前本体中的公理:");
        for (OWLAxiom axiom : ontology.getAxioms()) {
            System.out.println(" - " + axiom.toString());
        }
    }
}